#ifndef __NETWORK_H__
#define __NETWORK_H__
#define PORT 15532
extern char **localIps;
typedef struct{
    int id;
    const char* msg;
}ClientMessage;
//tool
void GetIPs();
void FreeIPs();
bool InitNetwork();
void StopNetwork();
void PrintIps(char **ips);
bool QueueSendDataToClientAndKickIfFail(int id, char* data);
bool BroadcastDataToClientExceptAndKickIfFail(char* data, int exceptId = -1);
//client
bool ConnectServer(char *serverIp);
void DisconnectServer(bool actively = false);
bool QueueSendDataToServer(char* data);
bool RegisterServerMessageHandler(void(*callback)(const char*));
void SetLostConnectionHandler(void(*callback)());
//server
bool StartServer();
void CloseServer();
void KickClient(int id);
bool IsClientOnline(int id);
int GetClientCount();
bool QueueSendDataToClient(int id, char* data);
bool BroadcastDataToClientExcept(char *data, int exceptID = -1);
bool BroadcastDataToClientExcept(char *data, int exceptID, int* &queueFulledClients);
bool RegisterClientMessageHandler(void(*callback)(ClientMessage*));
void SetClientDisconnectHandler(void(*callback)(int));
//broadcaster
bool StartBroadcast();
void StopBroadcast();
//udprecever
bool StartFindRoom();
void StopReceiveUdp();
#endif